import os

class Config:
    #数据库参数配置
    MYSQL_DIALECT = 'mysql'
    MYSQL_DRIVER = 'pymysql'
    MYSQL_USERNAME = 'root'
    MYSQL_PASSWORD = ''
    MYSQL_HOST = 'localhost'
    MYSQL_PORT = 3306
    MYSQL_DB = 'flask_shop'
    MYSQL_CHARSET = 'utf8mb4'

    #数据库连接uri
    SQLALCHEMY_DATABASE_URI = f'{MYSQL_DIALECT}+{MYSQL_DRIVER}://{MYSQL_USERNAME}:{MYSQL_PASSWORD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}?charset={MYSQL_CHARSET}'
    #数据盐
    SECRET_KEY = os.urandom(16)
    #设置数据不适用ASCII码
    JSON_AS_ASCII=False
    RESTFUL_JSON = {'ensure_ascii':False}
    #设置token过期时间
    JWT_EXPIRATION_DELTA = 60*60*24*7
    #设置可以上传的图片类型
    ALLOWED_EXTENSIONS = ['jpg','png','gif','jpeg']
    #获取当前目录的根路径
    BASE_URI = os.path.dirname(os.path.abspath(__file__))
    #设置图片上传的路径
    UPLOAD_FOLDER = os.path.join(BASE_URI,'flask_shop','static/upload')
    #设置debug
    DEBUG=True

#开发环境
class DevelopmentConfig(Config):
    DEBUG=True
#生产环境
class ProductConfig(Config):
    DEBUG=False
#测试环境
class TestingmentConfig(Config):
    pass

mapConfig = {
    'develop':DevelopmentConfig,
    'product':ProductConfig,
    'testing':TestingmentConfig,
}